import { pa } from 'element-plus/es/locale';
import http from '../utils/http';

//在这完成对api的封装
const user = "/users"
const admin = "/admin"
const news = "/news"
const category = "/category"
const comment = "/comment"

export default {

    // 用户接口
    userLogin(params?: any) {
        return http.get(`${user}/login`, params)
    },

    userRegister(params?: any) {
        const data = {
            user: params.user,
            identifying_code: params.identifying_code
        }
        return http.post(`${user}/register`, data)
    },

    userUpdata(params?: any) {
        return http.put(`${user}/update_user`, params)
    },

    userlogout(params?: any) {
        return http.get(`${user}/logout`, params)
    },

    //管理员接口
    AdminLogin(params?: any) {
        return http.get(`${admin}/login`, params)
    },

    AdminUpdata(params?: any) {
        return http.put(`${admin}/update_user`, params)
    },

    Adminlogout(params?: any) {
        return http.get(`${admin}/logout`, params)
    },

    // 新闻接口
    NewsAddNews(params?: any) {
        return http.post(`${news}/add`, params)
    },

    selectNews(params?: any) {
        return http.get(`${news}/page`, params)
    },

    DeleteNews(params?: any) {
        return http.delete(`${news}/delete`, params)
    },

    UpdateNews(params?: any) {
        return http.put(`${news}/update`, params)
    },

    unapproved(params?: any) {
        return http.get(`${news}/unapproved`, params)
    },

    approved(params?: any) {
        return http.get(`${news}/approved`, params)
    },

    newscheck(params?: any) {
        return http.put(`${news}/check`, params)
    },

    newsnocheck(params?: any) {
        return http.put(`${news}/nocheck`, params)
    },

    reverse(params?: any) {
        return http.get(`${news}/reverse`, params)
    },

    newsclick(params?: any) {
        return http.put(`${news}/click`, params)
    },

    //新闻栏目接口
    selectallcategory(params?: any) {
        return http.get(`${category}/selectAllCategory`, params)
    },

    selectcategoryId(params?: any) {
        return http.get(`${category}/${params}`)
    },

    deletecategory(params?: any) {
        return http.delete(`${category}/deleteCategory`, params)
    },

    updatecategory(params?: any) {
        return http.put(`${category}/updateCategory`, params)
    },

    addcategory(params?: any) {
        return http.post(`${category}/addCategory`, params)
    },

    //新闻评论接口
    selectcom(params?: any) {
        return http.get(`/newsComment`, params)
    },

    addcomment(params?: any) {
        return http.post(`${comment}/add`, params)
    },

    delcomment(params?: any) {
        return http.delete(`${comment}/delete`, params)
    },

    getcom(params?: any) {
        return http.get(`${comment}/select`, params)
    },

    updatecom(params?: any) {
        return http.put(`${comment}/update`, params)
    },

    addcollection(params?: any) {
        return http.post(`/collection/addCollection`, params)
    },

    delcollection(params?: any) {
        return http.delete(`/collection/deleteCollection`, params)
    },

    getcollection(params?: any) {
        return http.get(`/collection/selectCollection`, params)
    },

    addapprove(params?: any) {
        return http.post(`/approve/addApprove`, params)
    },

    delapprove(params?: any) {
        return http.delete(`/approve/deleteApprove`, params)
    },

    getApprove(params?: any) {
        return http.get(`/approve/selectAllApprove`, params)
    },

    getNewsById(params?: any) {
        return http.get(`${news}/all`, params)
    },

    approvedAll(params?: any) {
        return http.get(`${news}/approvedAll`,params)
    }
}